librosa from array to audio

45

import numpy as np
import soundfile as sf
rate = 44100
data = np.random.uniform(-1, 1, size=(rate * 10, 2))
# Write out audio as:
# 24bit PCM WAV
sf.write('stereo_file.wav', data, rate, subtype='PCM_24')
# 24bit Flac
sf.write('stereo_file.flac', data, rate, format='flac', subtype='PCM_24')
# 16bit OGG
sf.write('stereo_file.ogg', data, rate, format='ogg', subtype='vorbis')

Comments

Submit
0 Comments